{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from selenium.webdriver import Chrome\n",
    "import time\n",
    "import csv\n",
    "from selenium.webdriver.common.keys import Keys\n",
    "page=5\n",
    "def seach(key):\n",
    "    web.maximize_window()\n",
    "    time.sleep(0.1)\n",
    "    web.find_element_by_xpath('//*[@id=\"header-search\"]/div[1]/input[2]').send_keys(key)\n",
    "    time.sleep(0.5)\n",
    "    web.find_element_by_xpath('//*[@id=\"header-search\"]/div[2]/button').click()\n",
    "    time.sleep(0.5)\n",
    "def product():\n",
    "   \n",
    "    \n",
    "    res=web.find_elements_by_xpath('//div[@class=\"task_class_list_li\"]/div[@class=\"task_class_list_li_box\"]')\n",
    "    #res=web.find_elements_by_xpath('/html/body/div[10]/div[1]/div[2]/div[4]/div/div[1]/h3/a')\n",
    "    for i in res:\n",
    "        \n",
    "        global page\n",
    "        print(page)\n",
    "        \n",
    "        web.implicitly_wait(3)\n",
    "        url='/html/body/div[10]/div[1]/div[2]/div[4]/div%s/div[1]/h3/a'%([page])\n",
    "    \n",
    "        print(url)\n",
    "        web.find_element_by_xpath(url).send_keys(Keys.ENTER)\n",
    "        page+=1\n",
    "        time.sleep(1)\n",
    "        \n",
    "        \n",
    "        time.sleep(1)\n",
    "        web.switch_to.window(web.window_handles[-1])\n",
    "        name=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[1]/div[2]/div[1]/a').text\n",
    "        work=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[1]/div[2]/div[3]').text\n",
    "        money=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[3]/div[1]/div/div[2]/div[1]/span[1]/span').text\n",
    "        finall=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[3]/div[4]/div[1]/div[2]').text\n",
    "        print(name,work,money,finall)\n",
    "        print('*'*50)\n",
    "        web.close()\n",
    "        web.switch_to.window(web.window_handles[0])\n",
    "        time.sleep(2)\n",
    "        \n",
    "       \n",
    "        \n",
    "    \n",
    "    \n",
    "#     for i in res:\n",
    "#         i.find_element_by_xpath('.//h3[@class=\"a2\"]/a').click().perform()\n",
    "#         #确定窗口\n",
    "#         time.sleep(1)\n",
    "#         web.switch_to.window(web.window_handles[-1])\n",
    "#         name=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[1]/div[2]/div[1]/a').text\n",
    "#         work=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[1]/div[2]/div[3]').text\n",
    "#         money=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[3]/div[1]/div/div[2]/div[1]/span[1]/span').text\n",
    "#         finall=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[3]/div[4]/div[1]/div[2]').text\n",
    "#         print(name,work,money,finall)\n",
    "#         print('*'*50)\n",
    "#         time.sleep(3)\n",
    "#         web.close()\n",
    "#         web.switch_to.window(web.window_handles[0])\n",
    "#         time.sleep(10)\n",
    "        \n",
    "#     web.find_element_by_xpath('/html/body/div[10]/div[1]/div[2]/div[4]/div[1]/div[1]/h3/a').click()\n",
    "\n",
    "\n",
    "\n",
    "def main():\n",
    "    seach(key)\n",
    "    product()\n",
    "    \n",
    "\n",
    "if __name__=='__main__':\n",
    "    web=Chrome()\n",
    "    web.get('https://www.epwk.com/')\n",
    "    key=input('请输入内容: ')\n",
    "    main()\n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['http://www.epwk.com/zt/zhushou1510/', 'http://app.epweike.com/down.php?source=web&amp;type=iphone_weike&amp;down=1', 'http://app.epweike.com/down.php?source=web&amp;type=android_weike&amp;down=1', 'http://www.epwk.com/zt/zhongbao1511/', 'http://app.epwk.com/down.php?source=web&type=android_employer&down=1', 'http://shang.epwk.com/', 'http://bang.epwk.com/', 'http://dasai.epwk.com/', 'http://zhizao.epwk.com/', 'http://fy.epwk.com/', 'http://ys.epwk.com/', 'http://huizhan.epwk.com/', 'https://mall.epwk.com/', 'https://daka.epwk.com/', 'http://zt.epwk.com/channel/hezuo/', 'http://dasai.epwk.com/', 'http://dm.epwk.com/', 'http://ckt.epwk.com/', 'http://www.epjike.com/', 'http://www.ktbiao.com/', 'https://www.epwk.com/anli', 'https://www.epwk.com/article.html', 'https://www.epwk.com/zl/', 'https://ytby.epweike.com/', 'http://zt.epwk.com/ppfzjh-01/', 'https://www.epwk.com/review.html', 'https://www.epwk.com/prom/', 'https://gonglue.epwk.com/', 'http://s.epwk.com/', 'https://ask.epwk.com/', 'https://shop.epwk.com/', 'https://www.epwk.com/zt/', 'https://www.epwk.com/so/', 'https://www.epwk.com/integrity-view-gz.html', 'http://zt.epwk.com/1701banquanws/index.html', 'https://www.epwk.com/jingbiao.html', 'https://www.epwk.com/epcontract-view-index.html', 'https://i.epwk.com/Home/Witkey/wlevel.html', 'https://i.epwk.com/Home/Witkey/elevel.html', 'https://www.epwk.com/task-view-evaluation.html', 'https://www.epwk.com/vip/story/', 'https://www.epwk.com/guzhu/', 'https://www.xwzn.cn/?epi=1091531&utm_source=epwk&utm_content=nav', 'https://www.xwzn.cn/?epi=1091531&utm_source=epwk&utm_content=nav', 'https://logo.xwzn.cn/?epi=35&utm_source=epwk&utm_medium=&utm_campaign=&utm_content=nav&utm_term=', 'https://qiming.xwzn.cn/?epi=1474584&utm_source=epwk&utm_medium=&utm_campaign=%E5%B0%8F%E5%A8%81%E8%B5%B7%E5%90%8D&utm_content=%E7%BD%91%E7%AB%99%E5%AF%BC%E8%88%AA&utm_term=%E5%B0%8F%E5%A8%81%E8%B5%B7%E5%90%8D%E5%AE%98%E7%BD%91', 'http://www.epbiao.com/?utm_source=epwk&utm_content=nav', 'http://www.epbiao.com/?utm_source=epwk&utm_content=nav', 'http://www.epzcw.com/zt/shangbiaocx/?utm_source=epwk', 'http://www.epzcw.com/zt/shangbiaozc/?utm_source=epwk', 'http://www.epcsw.com/?utm_source=epwk&utm_content=nav', 'http://www.epcsw.com/?utm_source=epwk&utm_content=nav', 'http://www.epcsw.com/zhuce/', 'http://www.epcsw.com/jizhang/', 'http://www.epyxw.cn/?utm_source=epwk&utm_content=nav', 'http://www.epyxw.cn/?utm_source=epwk&utm_content=nav', 'http://www.epyxw.cn/projectCenter?epi=121&utm_source=epwk&utm_medium=&utm_campaign=&utm_content=&utm_term=', 'http://www.epyxw.cn/emip?epi=121&utm_source=epwk&utm_medium=&utm_campaign=&utm_content=&utm_term=', 'http://www.epyxw.cn/service/issue?epi=121&utm_source=epwk&utm_medium=&utm_campaign=&utm_content=&utm_term=', 'http://www.youqiwu.com/?utm_source=epwk&utm_content=nav', 'http://www.youqiwu.com/?utm_source=epwk&utm_content=nav', 'http://www.youqiwu.com/jzcase/', 'http://xiamen.youqiwu.com/xiaoz/', 'http://www.qzrzbj.com/rzfw/?utm_source=epwk&utm_content=nav', 'http://www.qzrzbj.com/rzfw/?utm_source=epwk&utm_content=nav', 'http://www.qzrzbj.com/rzfw/?utm_source=epwk', 'http://www.qzrzbj.com/rzfw/rzlc/?utm_source=epwk', 'http://www.qzrzbj.com/rzfw/rzxz/', 'https://www.epwk.com/vip/', 'https://www.epwk.com/integrity-view-gz.html', 'http://zt.epwk.com/1705_epyx/', 'https://www.epwk.com/release.html', 'https://mall.epwk.com/', 'http://www.epwk.com/zt/zhushou1510/', 'https://www.epwk.com/zt/trademark', 'https://ytby.epweike.com', 'https://www.epwk.com/zt/zhushou1510/', 'https://www.epwk.com/task/862733/', 'https://www.epwk.com/task/862899/', 'javascript:;', 'https://www.epwk.com/task/863226/', 'javascript:;', 'https://www.epwk.com/task/863606/', 'https://www.epwk.com/task/862774/', 'javascript:;', 'javascript:;', 'https://www.epwk.com/task/863548/', 'https://www.epwk.com/task/863113/', 'https://www.epwk.com/task/863272/', 'https://www.epwk.com/task/863486/', 'javascript:;', 'javascript:;', 'https://www.epwk.com/task/861829/', 'https://www.epwk.com/task/863664/', 'https://www.epwk.com/task/863639/', 'https://www.epwk.com/task/862665/', 'https://www.epwk.com/task/863528/', 'javascript:;', 'javascript:;', 'https://www.epwk.com/task/863586/', 'https://www.epwk.com/task/863611/', 'javascript:;', 'javascript:;', 'javascript:;', 'https://www.epwk.com/task/863565/', 'https://www.epwk.com/task/863576/', 'https://www.epwk.com/task/863553/', 'https://www.epwk.com/task/863535/', 'javascript:;', 'javascript:;', 'javascript:;', 'https://www.epwk.com/task/863493/', 'https://www.epwk.com/task/863481/', 'https://www.epwk.com/task/863431/', 'https://www.epwk.com/task/863478/', 'https://www.epwk.com/task/863492/', 'https://www.epwk.com/task/863474/', 'https://www.epwk.com/task/863477/', 'https://www.epwk.com/task/863465/', 'javascript:;', 'javascript:;', 'javascript:;', 'https://www.epwk.com/task/863455/', 'https://www.epwk.com/task/859559/', 'https://www.epwk.com/task/863446/', 'javascript:;', 'https://www.epwk.com/task/863375/', 'https://www.epwk.com/task/863439/', 'https://www.epwk.com/task/863437/', 'https://www.epwk.com/task/863422/', 'https://www.epwk.com/task/863420/', 'https://www.epwk.com/task/863372/', 'javascript:;', 'javascript:;', 'https://www.epwk.com/task/863383/', 'https://www.epwk.com/task/863377/', 'https://www.epwk.com/task/863366/', 'javascript:;', 'javascript:;', 'https://www.epwk.com/task/863611/', 'https://www.epwk.com/task/863598/', 'https://www.epwk.com/task/863565/', 'https://www.epwk.com/task/863528/', 'https://www.epwk.com/task/863493/', 'https://www.epwk.com/task/863486/', 'https://www.epwk.com/task/863481/', 'https://www.epwk.com/task/863465/', 'https://www.epwk.com/task/863446/', 'https://www.epwk.com/task/863439/', 'https://www.epwk.com/special-view-case_info-art_id-258579.html', 'https://www.epwk.com/special-view-case_info-art_id-258579.html', 'https://shop.epwk.com/4008028/', 'https://www.epwk.com/task/617210/', 'https://www.epwk.com/special-view-case_info-art_id-258510.html', 'https://www.epwk.com/special-view-case_info-art_id-258510.html', 'https://shop.epwk.com/4183670/', 'https://www.epwk.com/task/786841/', 'https://www.epwk.com/special-view-case_info-art_id-258507.html', 'https://www.epwk.com/special-view-case_info-art_id-258507.html', 'https://shop.epwk.com/4195536/', 'https://www.epwk.com/task/792555/', 'https://www.epwk.com/baike/logosj/', 'https://www.epwk.com/baike/wxkf/', 'https://www.epwk.com/baike/bzsj/', 'https://www.epwk.com/baike/gsqm/', 'https://www.epwk.com/baike/yxkf/', 'https://www.epwk.com/baike/jkkf/', 'https://www.epwk.com/baike/gswzjs/', 'https://www.epwk.com/baike/scwzjs/', 'https://www.epwk.com/baike/xxwzjs/', 'https://www.epwk.com/baike/sjwzkf/', 'https://shop.epwk.com/4207895/chushou/idea_157684.html', 'https://shop.epwk.com/4207895/chushou/idea_157684.html', 'https://shop.epwk.com/4208786/chushou/idea_157662.html', 'https://shop.epwk.com/4208786/chushou/idea_157662.html', 'https://shop.epwk.com/4205308/chushou/idea_141796.html', 'https://shop.epwk.com/4205308/chushou/idea_141796.html', 'https://shop.epwk.com/4208839/chushou/idea_157675.html', 'https://shop.epwk.com/4208839/chushou/idea_157675.html', 'https://shop.epwk.com/4177954/chushou/idea_157674.html', 'https://shop.epwk.com/4177954/chushou/idea_157674.html', 'https://www.epwk.com/task/863664/', 'https://www.epwk.com/task/863639/', 'https://www.epwk.com/task/863611/', 'https://www.epwk.com/task/863606/', 'https://www.epwk.com/task/863598/', 'https://www.epwk.com/task/863590/', 'https://www.epwk.com/task/863586/', 'https://www.epwk.com/task/863576/', 'https://www.epwk.com/task/863565/', 'https://www.epwk.com/task/863561/', 'https://www.epwk.com/vip/', 'https://www.epwk.com', 'https://www.epwk.com/meiti/', 'https://www.epwk.com/anli/', 'https://www.epwk.com/anli/', 'https://www.epwk.com/zt/', 'https://www.epwk.com/guzhu/', 'https://www.epwk.com/weike/', 'https://www.epwk.com/help/', '{{ .LinkURL }}', '{{ .LinkURL }}', 'https://{{ .Pinyin }}.{{ $.envSufix}}/', 'https://{{ .Pinyin }}.{{ $.envSufix}}/', \"' + USERURL + '\", \"' + USERURL + '/User/Basicinfo/index.html\", \"' + USERURL + '/Finance/Index/index.html\", \"' + USERURL + '/Finance/Recharge/index.html\", \"' + USERURL + '/Finance/Rewithdraw/index.html\", \"' + SITEURL + '/index.php?do=user&view=index\", \"' + SITEURL + '/index.php?do=user&view=index\", \"' + SITEURL + '/index.php?do=user&view=finance&op=detail\", \"' + SITEURL + '/index.php?do=user&view=finance&op=recharge\", \"' + SITEURL + '/index.php?do=user&view=finance&op=withdraw\"]\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "from fake_useragent import UserAgent\n",
    "import re\n",
    "useragent=UserAgent().chrome\n",
    "headers={\n",
    "    'User-Agent':useragent\n",
    "}\n",
    "res=requests.get('https://www.epwk.com/task/',headers)\n",
    "\n",
    "res=re.findall('<a.*?href=\"(.*?)\".*?target=\"_blank\">',res.text)\n",
    "print(res)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
